package server;

public class ScheduleProblem implements GenericGA {

	private ScheduleIndividual[] population;
	private ScheduleIndividual bestIndividual;
	private ScheduleConflicts sCons;
	
	private int nClass;
	private int tSlot;
	
	/**
	 * The constructor for the ScheduleProblem class, which will create an
	 * empty array of size @param size for the population, as well as an
	 * array of the same size for the fitness .
	 * <p>
	 * @param popSize	Gives the size of the population desired
	 * @param indivSize Gives the desired length of each {@link ScheduleIndividual}
	 * @param timeSlots 
	 */
	public ScheduleProblem(int popSize, int numClasses, 
			ScheduleConflicts conflicts, int timeSlots){
		
		population = new ScheduleIndividual[popSize];
		sCons = conflicts;
		nClass = numClasses;
		tSlot = timeSlots;
	}
	/**
	 * This will call upon each element of the {@link ScheduleIndividual} 
	 * class to populate itself randomly, then calculate the fitness of 
	 * the new gene, and place the new ScheduleIndividual into our array,
	 * and its fitness in the fitness array.
	 */
	public void populateRandomly() {
		
		for (int i = 0; i < population.length; i++){
			
			ScheduleIndividual si = new ScheduleIndividual(nClass, tSlot, sCons);
			si.populateRandomly();
			
			//Place these into the arrays
			population[i] = si;
		}
		
		//Make sure to make a reference to the best individual. Is this a copy?
		//I don't think I want a copy. How do you get a reference in java?
		double bestFitness = 0.0;
		for (int i = 0; i < population.length; i++){
			
			if (population[i].getFitness() > bestFitness){
				bestIndividual = population[i];
			}
		}	
	}

	@Override
	public void populateFromCS() {
		// TODO Auto-generated method stub

	}

	@Override
	public void reproduce() {
		// TODO Auto-generated method stub

	}

	@Override
	public GenericGA[] split() {
		// TODO Auto-generated method stub
		return null;
	}

}
